#!D:/CODE/python
# -*- coding: utf-8 -*-
# @Time : 2020/5/25 15:40
# @Author : Alexdong
# @Site : 
# @File : 通过send唤醒生成器.py
# @Software: PyCharm
# Functional description:


def create_num(all_num):
    a, b = 0, 1
    current_num = 0
    while current_num < all_num:
        args = yield a
        print('args=', args)
        a, b = b, a+b
        current_num += 1

obj = create_num(10)

ret = next(obj)
print(ret)

# 通过send方法唤醒生成器，可以往生成器里传参数
# 可以通过send()把参数传入，给一个新的值，相当于重新赋值
ret = obj.send("haha")
print(ret)